home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-09-28 | 2.7 KB | 116 lines | [TEXT/MPS ] |
- /* File: ControlKeyPatch.a.c
-
- Description:
- routines for patching the ADB manager to simulate the control
- key being held down. This file contains the 68000 code for
- the patch resource. It is identical to the file ControlKeyPatch.a
- except it is reformatted for use with CodeWarrior.
-
- Author: John Montbriand
-
- Copyright:
- Copyright © 1999 by Apple Computer, Inc.
- All rights reserved worldwide.
-
- Disclaimer:
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-
- Change History (most recent first):
- 27/8/99 created by John Montbriand
- */
-
- enum {
- command = 0, /* key down command */
- downflag = 4, /* flag for tracking key */
- originaljump = 8, /* original service routine */
- originaldata = 12 /* original service routine's data */
- };
-
- asm void __Startup__(void) {
-
- bra.s ADBPatch
- bra.s SetDown
- bra.s SetUp
-
-
- controldown: dc.l 0x0236FF00
-
- controlup: dc.l 0x02B6FF00
-
- SetDown:
- movea.l 4(SP), A2
- cmpi.l #1, downflag(A2) // test to see if the key is already down
- beq.s SetDownExit
- // set the down flag to true
- move.l #1, downflag(A2)
- // jump to the original service routine
- move.l command(A2), D0
- lea controldown, A0
- movea.l #0, A1
- move.l originaljump(A2), -(SP)
- movea.l originaldata(A2), A2
- rts
-
- SetDownExit:
- rts
-
- SetUp:
- movea.l 4(SP), A2
- cmpi.l #0, downflag(A2) // test to see if the key is already up
- beq.s SetUpExit
- // set the down flag to false
- move.l #0, downflag(A2)
- // jump to the original service routine
- move.l command(A2), D0
- lea controlup, A0
- movea.l #0, A1
- move.l originaljump(A2), -(SP)
- movea.l originaldata(A2), A2
- rts
-
- SetUpExit:
- rts
-
- ADBPatch:
- // R0?
- btst #0, D0
- bne.s @1
- btst #1, D0
- bne.s @1
- // talk?
- btst #2, D0
- beq.s @1
- btst #3, D0
- beq.s @1
- // test to see if the key is locked down
- cmpi.l #1, downflag(A2) // test to see if the key is down
- bne.s @1
- // block key downs
- cmpi.b #0x02, 0(A0)
- bne.s @2
- cmpi.b #0x36, 1(A0)
- bne.s @2
- cmpi.b #0xFF, 2(A0)
- bne.s @2
- rts
- @2: // block key ups
- cmpi.b #0x02, 0(A0)
- bne.s @1
- cmpi.b #0xB6, 1(A0)
- bne.s @1
- cmpi.b #0xFF, 2(A0)
- bne.s @1
- rts
- @1: // jump through to the original routine
- move.l originaljump(A2), -(SP)
- movea.l originaldata(A2), A2
- rts
-
- }
-